package org.example.utils;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;

import javax.servlet.http.HttpServletResponse;
@Slf4j
public class ResponseUtil {

    public static void out(HttpServletResponse response,Result result){
        response.setContentType("application/json;charset=utf-8");
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            objectMapper.writeValue(response.getOutputStream(),result);
        } catch (Exception e) {
            log.info("response返回数据,产生错误: {} , \n {}",e.getMessage(),e);
        }
    }
}
